package org.hibernate.tutorial.domain;

//non va usato java.sql.Date
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

public class Event {
    private Long id;
    
    private String title;
	private Date date;

    private Set participants = new HashSet();

    public Set getParticipants() {
        return participants;
    }

    public void setParticipants(Set participants) {
        this.participants = participants;
    }
    
    public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	@Override
	public String toString() {
		return "Event [id=" + id + ", title=" + title + ", date=" + date + "]";
	}

// Duali	
//    public void addToEvent(Event event) {
//        this.getEvents().add(event);
//        event.getParticipants().add(this);
//    }
//
//    public void removeFromEvent(Event event) {
//        this.getEvents().remove(event);
//        event.getParticipants().remove(this);
//    }
    
    public void addPerson(Person person) {
    	// queste due istruzioni si possono invertire
        this.getParticipants().add(person);
        person.getEvents().add(this);
    }

    public void removePerson(Person person) {
    	// queste due istruzioni si possono invertire
        person.getEvents().remove(this);
        this.getParticipants().remove(person);
    }

}
